package com.kaishengit.action;

import java.util.List;
import java.util.Map;

import com.kaishengit.pojo.Discuss;
import com.kaishengit.pojo.User;
import com.kaishengit.service.DiscussService;
import com.kaishengit.util.DateUtil;
import com.opensymphony.xwork2.Action;
import com.opensymphony.xwork2.ActionContext;

public class DiscussAction {
	private DiscussService discussService;
	private Discuss discuss; 
	private Discuss df; 
	private List<Discuss> list;
	private String id;


	public String fabu() {
		discuss.setCreatetime(DateUtil.getNow());
		Map<String, Object> session=ActionContext.getContext().getSession();
		   User user=(User) session.get("user");
		   discuss.setUser(user);
		
		discussService.save(discuss);
		return Action.SUCCESS;
	} 
	public String fanhui() {
	 list =	discussService.find();
		return Action.SUCCESS;
	}
	
	public String del() {
		discussService.del(id);
		
		return Action.SUCCESS;
		
	}
	public String edit() {
		System.out.println(id);
		df= discussService.findById(id);
		return "success";
	}
	public  String update() {
		discuss.setCreatetime(DateUtil.getNow());
		
		Map<String, Object> session=ActionContext.getContext().getSession();
		   User user=(User) session.get("user");
		   discuss.setUser(user);
		discussService.update(discuss);
		return Action.SUCCESS;
	}
	//get set
	public List<Discuss> getList() {
		return list;
	}

	public void setList(List<Discuss> list) {
		this.list = list;
	}

	public Discuss getDiscuss() {
		return discuss;
	}
	public String excute() {
		return "success";
	}
	public void setDiscuss(Discuss discuss) {
		this.discuss = discuss;
	}
	public DiscussService getDiscussService() {
		return discussService;
	}

	public Discuss getDf() {
		return df;
	}

	public void setDf(Discuss df) {
		this.df = df;
	}

	public void setDiscussService(DiscussService discussService) {
		this.discussService = discussService;
	}

	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}
	
	
	
}
